<template>
  <div class="app-container">
    <el-card class="box-card" style="width: 100%">
      <template #header>
        <div class="card-header">
          <el-tag><span style="font-weight: bold;font-size: 20px">个人基础信息</span></el-tag>
          <el-button type="primary" @click="onSubmitEmployee" style="float: right;">保存</el-button>
        </div>
      </template>
      <el-form ref="employeeForm" :model="employee" label-width="100px" inline label-position="left">
        <div style="float: right;margin-right: 20px">
          <el-image :src="employee.avatarUrl" style="width: 200px;height: 200px;"></el-image>
          <el-upload
            class="upload-demo"
            ref="upload"
            action=""
            accept="image/jpeg,image/jpg,image/png,pdf"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            :limit="1"
            :on-exceed="handleExceed"
            :file-list="fileList"
            :http-request="uploadAvatar">
            <el-button size="small" type="primary" style="margin-left: 100%;margin-right: 100%">上传</el-button>
          </el-upload>
        </div>
        <el-form-item label="名字">
          <el-input v-model="employee.name" ></el-input>
        </el-form-item>
        <el-form-item label="身份证" >
          <el-input v-model="employee.idcard" ></el-input>
        </el-form-item>
        <el-form-item label="民族" >
          <el-select v-model="employee.nationId" filterable style="width: 190px" placeholder="请选择">
            <el-option
              v-for="item in nations"
              :key="item.id"
              :label="item.name"
              :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="政治背景" >
          <el-select v-model="employee.politicId" filterable style="width: 190px" placeholder="请选择">
            <el-option
              v-for="item in politic"
              :key="item.id"
              :label="item.name"
              :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="籍贯" >
          <el-input v-model="employee.nativeplace" ></el-input>
        </el-form-item>
        <el-form-item label="性别" >
          <el-select v-model="employee.gender" style="width: 190px" placeholder="请选择">
            <el-option
              v-for="item in gender"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="婚姻情况" >
          <el-select v-model="employee.wedlock" style="width: 190px" placeholder="请选择">
            <el-option
              v-for="item in wedlock"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="出生日期" >
          <el-date-picker v-model="employee.birthday"
                          style="width: 190px"
                          type="date" placeholder="选择日期时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="邮件">
          <el-input v-model="employee.email"></el-input>
        </el-form-item>
        <el-form-item label="手机号" >
          <el-input v-model="employee.phone"></el-input>
        </el-form-item>
        <el-form-item label="地址" :span="15" >
          <el-input v-model="employee.address" ></el-input>
        </el-form-item>
        <el-form-item label="专业"  >
          <el-input v-model="employee.specialty" ></el-input>
        </el-form-item>
        <el-form-item label="学校"  >
          <el-input v-model="employee.school" ></el-input>
        </el-form-item>
        <el-form-item label="最高学历"  >
          <el-select v-model="employee.degree" style="width: 190px" placeholder="请选择">
            <el-option
              v-for="item in degree"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </el-card>

    <div style="padding: 10px"></div>
    <el-card class="box-card" style="width: 100%">
      <template #header>
        <div class="card-header">
          <el-tag><span style="font-weight: bold;font-size: 20px">就业经历</span></el-tag>
          <el-button type="primary" @click="addJob" style="float: right;">添加</el-button>
        </div>
      </template>
      <el-table :data="jobList" style="width: 100%;" border>
        <el-table-column align="center" prop="company" label="公司" width="180">
          <template slot-scope="scope">
            {{ scope.row.company }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="position" label="职位">
          <template slot-scope="scope">
            {{ scope.row.position }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="content" label="内容">
          <template slot-scope="scope">
            {{ scope.row.content }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="begin" label="开始时间">
          <template slot-scope="scope">
            <el-date-picker readonly v-model="scope.row.begin"
                            type="date" placeholder="开始时间">
            </el-date-picker>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="end" label="结束时间">
          <template slot-scope="scope">
            <el-date-picker readonly v-model="scope.row.end"
                            type="date" placeholder="开始时间">
            </el-date-picker>
          </template>
        </el-table-column>

        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="primary" size="small" @click="editJob(scope)">编辑</el-button>
            <el-button type="danger" size="small" @click="removeJob(scope)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-dialog :visible.sync="jobDialogVisible" :title="jobDialogType==='edit'?'Edit Job':'New Job'">
      <el-form :model="job" label-width="90px" label-position="left">
        <el-form-item label="公司" prop="company">
          <el-input v-model="job.company" placeholder="公司"/>
        </el-form-item>
        <el-form-item label="职位" prop="position">
          <el-input v-model="job.position" placeholder="职位"/>
        </el-form-item>
        <el-form-item label="内容" prop="content">
          <el-input v-model="job.content" placeholder="内容"/>
        </el-form-item>
        <el-form-item label="开始时间" prop="begin">
          <el-date-picker
            v-model="job.begin"
            type="date" value-format="timestamp"
            placeholder="入职时间点">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间" prop="end">
          <el-date-picker
            v-model="job.end"
            type="date" value-format="timestamp"
            placeholder="入职时间点">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div style="text-align:right;">
        <el-button type="danger" @click="jobDialogVisible=false">取消</el-button>
        <el-button type="primary" @click="confirmForm">确定</el-button>
      </div>
    </el-dialog>

    <div style="padding: 10px"></div>
    <el-card class="box-card" style="width: 100%">
      <template #header>
        <div class="card-header">
          <el-tag><span style="font-weight: bold;font-size: 20px">教育经历</span></el-tag>
          <el-button type="primary" @click="addEdu" style="float: right;">添加</el-button>
        </div>
      </template>
      <el-table :data="educationList" style="width: 100%;" border>
        <el-table-column align="center" prop="school" label="学校" width="180">
          <template slot-scope="scope">
            {{ scope.row.school }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="degree" label="学历">
          <template slot-scope="scope">
            <el-select v-model="scope.row.degree" disabled style="margin-left: 10px;width: 80%" placeholder="请选择">
              <el-option
                v-for="item in degree"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="begin" label="开始时间">
          <template slot-scope="scope">
            <el-date-picker readonly v-model="scope.row.begin"
                            type="date" placeholder="开始时间">
            </el-date-picker>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="end" label="结束时间">
          <template slot-scope="scope">
            <el-date-picker readonly v-model="scope.row.end"
                            type="date" placeholder="开始时间">
            </el-date-picker>
          </template>
        </el-table-column>

        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="primary" size="small" @click="editEdu(scope)">编辑</el-button>
            <el-button type="danger" size="small" @click="removeEdu(scope)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-dialog :visible.sync="eduDialogVisible" :title="eduDialogType==='edit'?'Edit Education':'New Education'">
      <el-form :model="education" label-width="90px" label-position="left">
        <el-form-item label="学校" prop="school">
          <el-input v-model="education.school" placeholder="学校"/>
        </el-form-item>
        <el-form-item label="学历" prop="degree">
          <el-select v-model="education.degree" filterable placeholder="请选择">
            <el-option
              v-for="item in degree"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="开始时间" prop="begin">
          <el-date-picker
            v-model="education.begin"
            type="date" value-format="timestamp"
            placeholder="开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间" prop="end">
          <el-date-picker
            v-model="education.end"
            type="date" value-format="timestamp"
            placeholder="结束时间">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div style="text-align:right;">
        <el-button type="danger" @click="eduDialogVisible=false">取消</el-button>
        <el-button type="primary" @click="confirmForm">确定</el-button>
      </div>
    </el-dialog>

    <div style="padding: 10px"></div>
    <el-card class="box-card" style="width: 100%">
      <template #header>
        <div class="card-header">
          <el-tag><span style="font-weight: bold;font-size: 20px">获奖经历</span></el-tag>
          <el-button type="primary" @click="addPrize" style="float: right;">添加</el-button>
        </div>
      </template>
      <el-table :data="prizeList" style="width: 100%;" border>
        <el-table-column align="center" prop="title" label="奖项" width="180">
          <template slot-scope="scope">
            {{ scope.row.title }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="content" label="内容">
          <template slot-scope="scope">
            {{ scope.row.content }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="fileId" label="文件">
          <template slot-scope="scope">
            <el-image
            style="width: 100px; height: 100px"
            :src="scope.row.fileUrl">
          </el-image>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="awardTime" label="获奖时间">
          <template slot-scope="scope">
            <el-date-picker readonly v-model="scope.row.awardTime"
                            type="date" placeholder="获奖时间">
            </el-date-picker>
          </template>
        </el-table-column>

        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="primary" size="small" @click="editPrize(scope)">编辑</el-button>
            <el-button type="danger" size="small" @click="removePrize(scope)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-dialog :visible.sync="prizeDialogVisible" :title="prizeDialogType==='edit'?'Edit Prize':'New Prize'">
      <el-form :model="prize" label-width="90px" label-position="left">
        <el-form-item label="标题" prop="title">
          <el-input v-model="prize.title" placeholder="标题"/>
        </el-form-item>
        <el-form-item label="内容" prop="content">
          <el-input v-model="prize.content" placeholder="内容"/>
        </el-form-item>
        <el-form-item label="文件" prop="fileId">
          <el-upload
            class="upload-demo"
            ref="upload"
            action=""
            accept="image/jpeg,image/jpg,image/png"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            :limit="1"
            :on-exceed="handleExceed"
            :file-list="fileList"
            :http-request="uploadPrize">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="获奖时间" prop="awardTime">
          <el-date-picker v-model="prize.awardTime" value-format="timestamp"
                          type="date" placeholder="获奖时间">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div style="text-align:right;">
        <el-button type="danger" @click="prizeDialogVisible=false">取消</el-button>
        <el-button type="primary" @click="confirmForm">确定</el-button>
      </div>
    </el-dialog>

    <div style="padding: 10px"></div>
    <el-card class="box-card" style="width: 100%">
      <template #header>
        <div class="card-header">
          <el-tag><span style="font-weight: bold;font-size: 20px">项目经历</span></el-tag>
          <el-button type="primary" @click="addProject" style="float: right;">添加</el-button>
        </div>
      </template>
      <el-table :data="projectList" style="width: 100%;" border>
        <el-table-column align="center" prop="title" label="标题">
          <template slot-scope="scope">
            {{ scope.row.title }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="role" label="角色" width="180">
          <template slot-scope="scope">
            {{ scope.row.role }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="content" label="内容">
          <template slot-scope="scope">
            {{ scope.row.content }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="begin" label="开始时间">
          <template slot-scope="scope">
            <el-date-picker readonly v-model="scope.row.begin"
                            type="date" placeholder="开始时间">
            </el-date-picker>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="end" label="结束时间">
          <template slot-scope="scope">
            <el-date-picker readonly v-model="scope.row.end"
                            type="date" placeholder="开始时间">
            </el-date-picker>
          </template>
        </el-table-column>

        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="primary" size="small" @click="editProject(scope)">编辑</el-button>
            <el-button type="danger" size="small" @click="removeProject(scope)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-dialog :visible.sync="projectDialogVisible" :title="projectDialogType==='edit'?'Edit Project':'New Project'">
      <el-form :model="project" label-width="90px" label-position="left">
        <el-form-item label="标题" prop="title">
          <el-input v-model="project.title" placeholder="标题"/>
        </el-form-item>
        <el-form-item label="角色" prop="content">
          <el-input v-model="project.role" placeholder="角色"/>
        </el-form-item>
        <el-form-item label="内容" prop="content">
          <el-input v-model="project.content" placeholder="内容"/>
        </el-form-item>
        <el-form-item label="开始时间" prop="begin">
          <el-date-picker
            v-model="project.begin"
            type="date" value-format="timestamp"
            placeholder="开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结束时间" prop="end">
          <el-date-picker
            v-model="project.end"
            type="date" value-format="timestamp"
            placeholder="结束时间">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div style="text-align:right;">
        <el-button type="danger" @click="projectDialogVisible=false">取消</el-button>
        <el-button type="primary" @click="confirmForm">确定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>

import {
  addEdu,
  addEmployee, addJob, addPrize, addProject,
  getEducations,
  getJobs,
  getMyEmployee,
  getPrizes,
  getProjects, modifyEducation, modifyEmployee, modifyJob, modifyPrize, modifyProject,
  removeEducation,
  removeJob, removePrize, removeProject
} from '@/api/employee'
import { getNations } from '@/api/nation'
import { getPolitics } from '@/api/politic'
import { addUser, modifyAvatar, modifyUser } from '@/api/user'
import { addUserRole, deleteRole } from '@/api/role'
import { deepClone } from '@/utils'
import { upload } from '@/api/file'

const defaultEmployee = {
  id: '',
  name: '',
  gender: '',
  birthday: '',
  idcard: '',
  wedlock: '',
  politicId: '',
  nativeplace: '',
  email: '',
  phone: '',
  address: '',
  degree: '',
  specialty: '',
  school: ''
}
const defaultProject = {
  id: '',
}
const defaultPrize = {
  id: '',
}
const defaultEducation = {
  id: '',
}
const defaultJob= {
  id: '',
}
export default {
  name: 'EmployeeMine',
  components: {},
  data() {
    return {
      // 单个object
      employee: Object.assign({}, defaultEmployee),
      job: Object.assign({}, defaultJob),
      prize: Object.assign({}, defaultPrize),
      project: Object.assign({}, defaultProject),
      education: Object.assign({}, defaultEducation),
      // 列表
      jobList: [],
      prizeList: [],
      projectList: [],
      educationList: [],
      fileList: [],
      // 表单
      jobDialogType: 'new',
      jobDialogVisible: false,
      prizeDialogType: 'new',
      prizeDialogVisible: false,
      projectDialogType: 'new',
      projectDialogVisible: false,
      eduDialogType: 'new',
      eduDialogVisible: false,
      formType: '',
      // 常量枚举
      nations: [],
      politic: [],
      // 枚举类
      degree: [
        {value: 'OTHER', label: "其他"},
        {value: 'SPECIALTY', label: "大专"},
        {value: 'UNDERGRADUATE', label: "本科"},
        {value: 'MASTER', label: "硕士研究生"},
        {value: 'DOCTOR', label: "博士"}
      ],
      gender: [
        {value: 'FEMALE', label: "女性"},
        {value: 'MALE', label: "男性"}
      ],
      wedlock: [
        {value: 'MARRIED', label: "已婚"},
        {value: 'UNMARRIED', label: "未婚"}
      ],
    };
  },
  //监听属性 类似于data概念
  created() {
    this.getEmployee()
    this.getNationAndPolitic()
    this.$notify.info({
      title: '提示',
      message: '请完善个人信息',
      duration: 0
    });
  },
  methods: {
    async getEmployee() {
      getMyEmployee().then((response)=>{
        this.employee = response.data
        this.employee.begin = ''
        this.employee.end = ''
        this.getProjects()
        this.getPrizes()
        this.getJobs()
        this.getEducations()
      })
    },
    async getJobs(){
       getJobs(this.employee.id).then((res)=>{
        this.jobList = res.data
      })
    },
    async getProjects(){
     getProjects(this.employee.id).then((res)=>{
        this.projectList = res.data
      })
    },
    async getPrizes(){
      getPrizes(this.employee.id).then((res)=>{
        this.prizeList =res.data
      })
    },
    async getEducations(){
     getEducations(this.employee.id).then((res)=>{
       this.educationList =res.data
     })
    },
    async getNationAndPolitic(){
      getNations().then((res)=>{
        this.nations = res.data
      })
      getPolitics().then((res)=>{
        this.politic = res.data
      })
    },
    onSubmitEmployee() {
      // 只有修改
      this.formType = 'employeeForm'
      this.confirmForm()
    },
    addProject() {
      this.project = Object.assign({}, defaultProject)
      this.formType = 'projectForm'
      this.projectDialogType='new'
      this.projectDialogVisible = true
    },
    editProject(scope) {
      this.formType = 'projectForm'
      this.projectDialogType='edit'
      this.projectDialogVisible = true
      this.project = deepClone(scope.row)
    },
    removeProject({ $index, row }) {
      this.$confirm('确定要删除吗?', 'Warning', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async() => {
          await removeProject(row.id)
          this.projectList.splice($index, 1)
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        })
        .catch(err => {
          console.error(err)
        })
    },
    addPrize() {
      this.prize = Object.assign({}, defaultPrize)
      this.formType = 'prizeForm'
      this.prizeDialogType='new'
      this.prizeDialogVisible = true
    },
    editPrize(scope) {
      this.formType = 'prizeForm'
      this.prizeDialogType='edit'
      this.prizeDialogVisible = true
      this.prize = deepClone(scope.row)
    },
    removePrize({ $index, row }) {
      this.$confirm('确定要删除吗?', 'Warning', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async() => {
          await removePrize(row.id)
          this.prizeList.splice($index, 1)
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        })
        .catch(err => {
          console.error(err)
        })
    },
    addJob() {
      this.job = Object.assign({}, defaultJob)
      this.formType = 'jobForm'
      this.jobDialogType = 'new'
      this.jobDialogVisible = true
    },
    editJob(scope) {
      this.formType = 'jobForm'
      this.jobDialogType = 'edit'
      this.jobDialogVisible = true
      this.job = deepClone(scope.row)
    },
    removeJob({ $index, row }) {
      this.$confirm('确定要删除吗?', 'Warning', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async() => {
          await removeJob(row.id)
          this.jobList.splice($index, 1)
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        })
        .catch(err => {
          console.error(err)
        })
    },
    addEdu() {
      this.education = Object.assign({}, defaultEducation)
      this.formType = 'eduForm'
      this.eduDialogType = 'new'
      this.eduDialogVisible = true
    },
    editEdu(scope) {
      this.formType = 'eduForm'
      this.eduDialogType = 'edit'
      this.eduDialogVisible = true
      this.education = deepClone(scope.row)
    },
    removeEdu({ $index, row }) {
      this.$confirm('确定要删除吗?', 'Warning', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async() => {
          await removeEducation(row.id)
          this.educationList.splice($index, 1)
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        })
        .catch(err => {
          console.error(err)
        })
    },
    async confirmForm() {
      if ('employeeForm' === this.formType) {
        if (this.employee.id === ''){
            await addEmployee(this.employee).then((res)=>{
              this.education.employeeId = res.data
              this.prize.employeeId = res.data
              this.project.employeeId = res.data
              this.job.employeeId = res.data
            })
        } else {
          await modifyEmployee(this.employee)
        }
      } else if ('eduForm' === this.formType) {
        if ('edit' === this.eduDialogType) {
          await modifyEducation(this.education)
          for (let index = 0; index < this.educationList.length; index++) {
            if (this.educationList[index].id === this.education.id) {
              this.educationList.splice(index, 1, Object.assign({}, this.education))
              break
            }
          }
        } else {
          this.education.employeeId = this.employee.id
          await addEdu(this.education)
          await this.getEducations()
        }
        this.eduDialogVisible = false
      } else if ('prizeForm' === this.formType) {
        if ('edit' === this.prizeDialogType) {
          await modifyPrize(this.prize)
          for (let index = 0; index < this.prizeList.length; index++) {
            if (this.prizeList[index].id === this.prize.id) {
              this.prizeList.splice(index, 1, Object.assign({}, this.prize))
              break
            }
          }
        } else {
          this.prize.employeeId = this.employee.id
          await addPrize(this.prize)
          await this.getPrizes()
        }
        this.prizeDialogVisible = false
      } else if ('projectForm' === this.formType) {
        if ('edit' === this.projectDialogType) {
          await modifyProject(this.project)
          for (let index = 0; index < this.projectList.length; index++) {
            if (this.projectList[index].id === this.project.id) {
              this.projectList.splice(index, 1, Object.assign({}, this.project))
              break
            }
          }
        } else {
          this.project.employeeId = this.employee.id
          await addProject(this.project)
          await this.getProjects()
        }
        this.projectDialogVisible = false
      } else if ('jobForm' === this.formType) {
        if ('edit' === this.jobDialogType) {
          await modifyJob(this.job)
          for (let index = 0; index < this.jobList.length; index++) {
            if (this.jobList[index].id === this.job.id) {
              this.jobList.splice(index, 1, Object.assign({}, this.job))
              break
            }
          }
        } else {
          this.job.employeeId = this.employee.id
          await addJob(this.job)
          await this.getJobs()
        }
        this.jobDialogVisible = false
      }
      this.$notify({
        title: 'Success',
        dangerouslyUseHTMLString: true,
        message: "操作成功",
        type: 'success'
      })
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
      this.prize.fileId = ''
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${ file.name }？`);
    },
    async uploadPrize(params) {
      let form = new FormData();
      this.$refs.upload.uploadFiles.forEach((file) => {
        form.append("file", file.raw);
      });
      await upload(form).then((res) => {
        this.prize.fileId = res.data
        // console.log(this.complementSign.fileId)
      })
      this.fileList = []
    },
    async uploadAvatar(params) {
      let form = new FormData();
      this.$refs.upload.uploadFiles.forEach((file) => {
        form.append("file", file.raw);
      });
      await upload(form).then((res) => {
        this.employee.fileId = res.data
        // console.log(this.contract.fileId)
      })
      await modifyAvatar(this.employee.fileId).then((res)=>{
        this.employee.avatarUrl = res.data
      })
      this.fileList = []
      this.$notify({
        title: 'Success',
        dangerouslyUseHTMLString: true,
        message: "操作成功, 头像上传过段时间会同步，请刷新等待",
        type: 'success'
      })
    },
  },
}
</script>

<style scoped>

</style>
